<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>添加或编辑界面</title>
    <link rel="stylesheet" type="text/css" href="${s.base}/lib/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/css/base/index.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/css/base/theme/theme.css"/>
    <style>
        .w440{
            width: 440px !important;
        }
        .w200{
            width: 215px !important;
        }
    </style>
</head>
<body>
<div class="page-content-wrap clearfix">
    <form class="layui-form" id="tool">
        <input type="hidden" name="applyId" value="${applyId}" />
        <div class="layui-tab">
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">

                    <div class="layui-form-item" id="area-picker">
                        <label class="layui-form-label"><span class="red">*</span>&nbsp;省市区：</label>
                        <div class="layui-input-inline" style="width: 140px;">
                            <select name="province" class="province-selector" data-value="<#if antiepidemicCommunity.provinceCode??>${antiepidemicCommunity.provinceCode}<#else>安徽省</#if>" lay-filter="province-1">
                                <option value="">请选择省</option>
                            </select>
                            <input id="provinceCode" name="provinceCode" type="hidden" value="<#if antiepidemicCommunity.provinceCode??>${antiepidemicCommunity.provinceCode}<#else>安徽省</#if>">
                        </div>
                        <div class="layui-input-inline" style="width: 140px;">
                            <select name="city" class="city-selector" data-value="<#if antiepidemicCommunity.cityCode??>${antiepidemicCommunity.cityCode}<#else>芜湖市</#if>" lay-filter="city-1">
                                <option value="">请选择市</option>
                            </select>
                            <input id="cityCode" name="cityCode" type="hidden" value="<#if antiepidemicCommunity.cityCode??>${antiepidemicCommunity.cityCode}<#else>芜湖市</#if>">
                        </div>
                        <div class="layui-input-inline" style="width: 140px;">
                            <select name="county" class="county-selector" data-value="<#if antiepidemicCommunity.regionCode??>${antiepidemicCommunity.regionCode}<#else>镜湖区</#if>" lay-filter="county-1">
                                <option value="">请选择区</option>
                            </select>
                            <input id="regionCode" name="regionCode" type="hidden" value="<#if antiepidemicCommunity.regionCode??>${antiepidemicCommunity.regionCode}<#else>镜湖区</#if>">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="red">*</span>&nbsp;小区名称：</label>
                        <div class="layui-input-inline w440">
                            <input type="text" name="buildingName" value="${antiepidemicCommunity.buildingName}" lay-verify="required" placeholder="请输入社区名称" autocomplete="off" class="layui-input" maxlength="200">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="red">*</span>&nbsp;出行次数：</label>
                        <div class="layui-input-inline" style="width: 205px;">
                            <input type="text" name="dayTripTimes" value="<#if dayTripTimes??>${dayTripTimes}<#else>1</#if>" lay-verify="required|number" placeholder="请输入出行次数（天）" autocomplete="off" class="layui-input" maxlength="200">
                        </div>
                        <div class="layui-input-inline" style="width: 10px;">
                        <span class="red">/</span>
                        </div>
                        <div class="layui-input-inline" style="width: 205px;">
                            <input type="text" name="frequencyTripTimes" value="<#if frequencyTripTimes??>${frequencyTripTimes}<#else>1</#if>" lay-verify="required|number" placeholder="请输入出行次数（次）" autocomplete="off" class="layui-input" maxlength="200">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="red">*</span>&nbsp;是否需要审核：</label>
                        <div class="layui-input-inline w440">
                            <select name="checkType" id="checkType" lay-verify="required" ></select>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="red">*</span>&nbsp;类型：</label>
                        <div class="layui-input-inline w440">
                            <select name="communityType" id="communityType" lay-filter="communityType" lay-verify="required" ></select>
                        </div>
                    </div>

                    <div class="layui-form-item" id="showGoTime" <#if antiepidemicCommunity == null || antiepidemicCommunity.communityType == "1">style="display: none"</#if>>
                        <label class="layui-form-label">&nbsp;上班时间段：</label>
                        <div class="layui-input-inline w200">
                            <input type="text" name="goStartWork" id="goStartWork" value="${antiepidemicCommunity.goStartWork}" placeholder="请输入上班时间段" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-input-inline w200">
                            <input type="text" name="goEndWork" id="goEndWork" value="${antiepidemicCommunity.goEndWork}" placeholder="请输入上班时间段" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item" id="showOffTime" <#if antiepidemicCommunity == null || antiepidemicCommunity.communityType == "1">style="display: none"</#if>>
                        <label class="layui-form-label">&nbsp;下班时间段：</label>
                        <div class="layui-input-inline w200">
                            <input type="text" name="offStartWork" id="offStartWork" value="${antiepidemicCommunity.offStartWork}" placeholder="请输入下班时间段" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-input-inline w200">
                            <input type="text" name="offEndWork" id="offEndWork" value="${antiepidemicCommunity.offEndWork}" placeholder="请输入下班时间段" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block" style="margin-left: 0px !important;text-align: center">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="submitBtn">提交</button>
                <button type="button" id="cancel" class="layui-btn layui-btn-primary">取消</button>
                <button type="button" style="display: none;" id="save" class="layui-btn layui-btn-primary"></button>
            </div>
        </div>
    </form>
</div>
<script src="${s.base}/lib/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="${s.base}/js/common.js" type="text/javascript" charset="utf-8"></script>
<script>
    layui.use(['jquery', 'form', 'baseutil','layarea','laydate','page'], function () {
        var $ = layui.jquery,
            form = layui.form,
            baseutil = layui.baseutil,
            page = layui.page,
            laydate = layui.laydate,
            layarea = layui.layarea;

        layarea.render({
            elem: '#area-picker',
            change: function (res) {
                //选择结果
                $("#provinceCode").val(res.province);
                $("#cityCode").val(res.city);
                $("#regionCode").val(res.county);
            }
        });

        page.initDict('community_type,community_is_check', function (dictData) {
            page.showDict($("#checkType"), page.aceeptDictContentList(dictData, 'community_is_check'), "请选择", '${antiepidemicCommunity.checkType}');
            page.showDict($("#communityType"), page.aceeptDictContentList(dictData, 'community_type'), "请选择", '${antiepidemicCommunity.communityType}');
        });

        form.on('select(communityType)', function(data){
            if (data.value == 2) {
                $("#showGoTime").show();
                $("#showOffTime").show();
            } else {
                $("#showGoTime").hide();
                $("#showOffTime").hide();
            }
        });

        laydate.render({elem: '#goStartWork', type: 'time', trigger: 'click'});
        laydate.render({elem: '#goEndWork', type: 'time', trigger: 'click'});
        laydate.render({elem: '#offStartWork', type: 'time', trigger: 'click'});
        laydate.render({elem: '#offEndWork', type: 'time', trigger: 'click'});

        //监听提交
        form.on('submit(submitBtn)', function (data) {
            data.field.id = '${antiepidemicCommunity.id}';
            data.field.maxTripTimes = data.field.dayTripTimes + "/" + data.field.frequencyTripTimes;
            baseutil.post("/work/antiepidemic/antiepidemiccommunity/addOrUpdate", data.field, function () {
                $("#save").click();
            });
            return false;
        });
    });
</script>
</body>
</html>